package com.chen.controller;

import com.chen.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {
//    非RestFul风格的形式，接受前端参数是用@RequestParam  否则用 @PathVariable
    @RequestMapping("/te")
    public String getName(@RequestParam("username") String name, Model model){
        System.out.println("前端结果为"+name);
        model.addAttribute("msg",name);
        return "test";
    }

    @RequestMapping("/user")
    public String getUser(User user,Model model){
        System.out.println(user);
        model.addAttribute("msg",user.toString());
        return "test";
    }
}
